home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 November / november_2001.iso / Browsers / Netscape 6.1 / browser.xpi / bin / chrome / net2phone.jar / content / net2phone / Net2Phone.js < prev    next >
Encoding:
Text File  |  2001-05-25  |  2.2 KB  |  60 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "License"); you may not use this file except in
  5.  * compliance with the License.  You may obtain a copy of the License at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the License is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  10.  * for the specific language governing rights and limitations under the
  11.  * License.
  12.  *
  13.  * The Original Code is Mozilla Communicator client code, 
  14.  * released March 31, 1998. 
  15.  *
  16.  * The Initial Developer of the Original Code is Netscape Communications 
  17.  * Corporation.  Portions created by Netscape are 
  18.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  19.  * Reserved.
  20.  *
  21.  * Contributors:
  22.  *     William A. ("PowerGUI") Law <law@netscape.com>
  23.  */
  24.  
  25. /* net2Phone
  26.  
  27.    This function is invoked when the user clicks on the Net2Phone personal
  28.    toolbar button, or, the Net2Phone Tasks menu choice.
  29.  
  30.    It accesses the nsINet2Phone service and invokes its "launch" method.
  31.  
  32.    If that fails for any reason (e.g., Net2Phone isn't installed yet)
  33.    then we show the info web page.
  34. */
  35. dump( "Net2Phone.js has been interpreted...\n" );
  36. function net2Phone( n2pURL ) {
  37.    // Get nsINet2Phone component instance.
  38.    var n2pContractId = "@mozilla.org/appshell/component/net2phone;1";
  39.    var n2pIID    = Components.interfaces.nsINet2Phone;
  40.    // var n2pURL    = "http://home.netscape.com/bookmark/6_1/n2phone.html";
  41.    var n2p = Components.classes[ n2pContractId ].getService( n2pIID );
  42.    if ( n2p ) {
  43.       // Launch it.
  44.       try {
  45.          if( !n2p.launch() ) {
  46.             // Unable to launch (but no error).  This means the user
  47.             // has not installed Net2Phone yet.  Clue them in by
  48.             // opening the appropriate web page.
  49.             openTopWin( n2pURL );
  50.          }
  51.       } catch ( exception ) {
  52.          // XXX l10n
  53.          alert( "Error launching Net2Phone" );
  54.       }
  55.    } else {
  56.       // XXX l10n
  57.       alert( "Error creating Net2Phone interface component" );
  58.    }
  59. }
  60.